package pro.shushi.pamirs.demo.core.manager;

import pro.shushi.pamirs.meta.annotation.Fun;
import pro.shushi.pamirs.meta.annotation.Function;
import pro.shushi.pamirs.meta.enmu.FunctionCategoryEnum;
import pro.shushi.pamirs.meta.enmu.FunctionOpenEnum;
import pro.shushi.pamirs.meta.enmu.FunctionTypeEnum;
import pro.shushi.pamirs.workflow.app.api.tmodel.CustomFunParam;

@Fun("demo.EipFunManager")
public class EipFunManager {

    /**
     * 数字类型转换为中文名称：1,2,3,4 对应 华为,苹果,三星,小米
     * @param customFunParam
     * @return
     */
    @Function(name = "calcCustomField",openLevel = FunctionOpenEnum.API)
    @Function.Advanced(type= FunctionTypeEnum.QUERY,displayName = "演示EIP类型转换",category = FunctionCategoryEnum.CUSTOM_DESIGNER )
    public CustomFunParam calcCustomField(CustomFunParam customFunParam){
        Object originData = customFunParam.getData();
        String targetData = null;
        if(originData == null) return customFunParam;
        long value = Integer.parseInt(String.valueOf(originData));
        if(value == 1){
            targetData = "华为";
        }else if(value == 2){
            targetData = "苹果";
        }else if(value == 3){
            targetData = "三星";
        }else if(value == 4){
            targetData = "小米";
        }
        customFunParam.setData(targetData);
        return customFunParam;
    }
}
